package org.acceleo.modules.uml2.services;


import fr.obeo.acceleo.gen.template.eval.ENodeCastException;

public class StringServices {

	/**
	 * Return the String with the first letter uppercase. Useful for class name.
	 */
	public String firstUpper(String s) throws ENodeCastException {
		if (s.length() > 0) 
			s = Character.toUpperCase(s.charAt(0)) + s.substring(1);
		return s;
	}

	/**
	 * Return the String with the first letter lowercase. Useful for attribute name.
	 */
	public String firstLower(String s) throws ENodeCastException {
		if (s.length() > 0) 
			s = Character.toLowerCase(s.charAt(0)) + s.substring(1);
		return s;
	}
	
	/**
	 * Transform a String with notation aa.bb.cc to aa/bb/cc<br/>
	 * Usefull for package translating.
	 */
	public String toPath(String packageName) throws ENodeCastException {
		return packageName.trim().replaceAll("\\.","/");
	}

}
